上回提到如何與CSS語法,感受到有很多強大的美化功能~
但其實光有CSS是不夠的,還要和HTML合作才能真正地用出來!
那如何與HTML合作呢?有三種常用的方法
inline CSS : 在HTML標籤中,使用style屬性,直接加入CSS
internal CSS : 在HTML檔案的<head>中加入<style>標籤來編寫CSS
external CSS : 將CSS寫在另一個檔案,藉由link標籤引入CSS文檔
了解這三種方式後,接下來分別詳細一點介紹
inline CSS
實作方式(在html檔)
<p style = "color:red;  
      background-color:blue;
		  font-size:18pt;">要顯示的字</p>
internal CSS
實作方式(在html檔) →所有有用此標籤(此例為p)的效果會一起更改:(
<head>
  <style>
    p{
      color:red;  
      background-color:blue;
		  font-size:18pt;
    }
  </style>
</head>
<body>
external CSS
在CSS檔(此例為style.css): 定義屬性
<div class = "style">div.style{
  background-color:blue;
  font-size:18pt;
}
在html檔 : 加上屬性
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>replit</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div class = "style">
</body>
如何使用別人做的CSS模板?
<link rel="test1" href="別人做好的網址.css">
先到這邊,明天見~~